<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>统计a的个数</title>
    <script >
        function f() {
            let arr=[]
            let counter=0;//计数器
            while (1){
                let sub=prompt("请输入：")
                if (sub===" "){
                    break//退出循环
                }/*else{

                } */
                //arr.unshift(sub)
                arr.push(sub);
                if (sub==="a"){
                    counter++

                }
            }
            alert("arr="+arr)
            alert("a出现的次数为："+counter+"次")
        }

        f()
    </script>
</head>
<body>

</body>
</html>